 
 
 
 
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentListener;
 
import java.util.ArrayList;
 

 
import javax.swing.ImageIcon;
 
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
 
 

 
public class PlayerDetailsPanel extends JPanel {
    
	private final int WIDTH = 900, HEIGHT =420; // panel size
	private JLabel nameLabel;
 
 
    
	private JLabel cashLabel;
	private JLabel cashPicLabel;
	private JLabel totalWorthPicLabel;
	private JLabel totalWorthLabel;
	private JLabel propsOwnedPicLabel;
	private JLabel propsOwnedLabel;
	 
	
	private JLabel cardLabel = new JLabel(); 
	
    private String cardsdir = "./scaledimages/";
    private String jailcardsdir = "./scaledjailimages/";
    
 
    private ArrayList<String> imageFileNames1;
    private ArrayList<String> imageFileNames2;
    private ArrayList<String> imageFileNames3;
    private ArrayList<String> imageFileNames4;
    private ArrayList<String> imageFileNames5;
    private ArrayList<String> imageFileNames6;
    private ArrayList<String> imageFileNames7;
    private ArrayList<String> imageFileNames8;
    private ArrayList<String> imageFileNames9;
    private ArrayList<String> imageFileNames10;
    
    private ArrayList<String> jailfreecards;
 
  
    
    private String imageExt = ".jpg";
    
    
    public PlayerDetailsPanel(String name, int cash, int totalWorth, int propsOwned, ArrayList<String> propertiesOwned,
    		ArrayList<String>JailFree) {
    	
    	//sortProperties sp = new sortProperties(propertiesOwned);
    	
    	imageFileNames1 = new ArrayList<String>();
    	imageFileNames2 = new ArrayList<String>();
    	imageFileNames3 = new ArrayList<String>();
    	imageFileNames4 = new ArrayList<String>();  
    	imageFileNames5 = new ArrayList<String>();  
    	imageFileNames6 = new ArrayList<String>();  
    	imageFileNames7 = new ArrayList<String>();  
    	imageFileNames8 = new ArrayList<String>();  
    	imageFileNames9 = new ArrayList<String>();   
    	imageFileNames10 = new ArrayList<String>();   
 
    	
		nameLabel = new JLabel("" +name);
	    nameLabel.setFont(new Font("Serif", Font.BOLD, 20));
		 
	    Icon totalcash =new ImageIcon("./playerpanelimages/totalcash.png");
	    
	    cashPicLabel = new JLabel(totalcash);
	    
		cashLabel = new JLabel("$" + cash );
		cashLabel.setFont(new Font("Serif", Font.BOLD, 25));
	 
		Icon totalworth =new ImageIcon("./playerpanelimages/totalworth.png");
		totalWorthPicLabel = new JLabel(totalworth);
	 
		
		totalWorthLabel = new JLabel("$" + totalWorth);
		totalWorthLabel.setFont(new Font("Serif", Font.BOLD, 25));
	 
		
		
		Icon propertiesowned =new ImageIcon("./playerpanelimages/propertiesowned.png");
		
		propsOwnedPicLabel = new JLabel(propertiesowned);
		
		propsOwnedLabel = new JLabel("" + propsOwned  );
		propsOwnedLabel.setFont(new Font("Serif", Font.BOLD, 25));
		 
 
		
       
		setLayout(new GridBagLayout());	
    	setPreferredSize (new Dimension(WIDTH, HEIGHT));
    	setBackground (new Color(200,222,186));
        
     
    	setPropertyRows(propertiesOwned);      
 
    	displaycards();
  
      
    	GridBagConstraints con = new GridBagConstraints();
		  
		 con.insets = new Insets(2, 5, 5, 0);
 
		con.gridx =0;
		con.gridy =0;
		add(nameLabel, con);

		con.gridx =1;
		con.gridy =0;
		add(cashPicLabel, con);
		
		con.gridx =2;
		con.gridy =0;
		add(cashLabel, con);
		       
		con.gridx =3;
		con.gridy =0;	
		add(totalWorthPicLabel, con); 
		
		con.gridx =4;
		con.gridy =0;
		add(totalWorthLabel, con); 
		
		con.gridx =5;
		con.gridy =0;
		add(propsOwnedPicLabel, con);

		con.gridx =6;
		con.gridy =0;
		add(propsOwnedLabel, con);
 
		int z =7;
	for ( int i = 0; i < JailFree.size(); i++)
		{
		    ImageIcon icon;
		    icon  =new ImageIcon(getClass().getResource(jailcardsdir + JailFree.get(i) + imageExt));
		    // icon  =new ImageIcon(jailcardsdir + JailFree.get(i) + imageExt));
		   
		
		 
		    
		cardLabel = new JLabel(icon);
		cardLabel.setToolTipText(JailFree.get(i));
		con.gridx =z;
		con.gridy =0;
		add(cardLabel, con);
		z++;
		
		}    

}   
       
 
 
  //  System.out.println(propertiesOwned);
   
	private  void setPropertyRows( ArrayList<String>propertiesOwned)	{
	int i=0;  
	
	for ( i = 0; i < propertiesOwned.size(); i++ )
	{	
		
		if ( propertiesOwned.get(i) == "MediterraneanAve" ){
			
				 
			imageFileNames1.add("MediterraneanAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "BalticAve" ){
			
			 
			imageFileNames1.add("BalticAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "VermontAve" ){
			
			 
			imageFileNames2.add("VermontAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "OrientalAve" ){
			
			 
			imageFileNames2.add("OrientalAve");		  
			
		}
		if ( propertiesOwned.get(i) == "ConnecticutAve" ){
			
			 
			imageFileNames2.add("ConnecticutAve");		  
			
		}
		
		if ( propertiesOwned.get(i) == "StCharlesPlace" ){
			
			 
			imageFileNames3.add("StCharlesPlace");		  
			
		}	
		if ( propertiesOwned.get(i) == "StatesAve" ){
			
			 
			imageFileNames3.add("StatesAve");		  
			
		}
		if ( propertiesOwned.get(i) == "VirginiaAve" ){
			
			 
			imageFileNames3.add("VirginiaAve");		  
			
		}
		if ( propertiesOwned.get(i) == "StJamesPlace" ){
			
			 
			imageFileNames4.add("StJamesPlace");		  
			
		}	
		if ( propertiesOwned.get(i) == "TennesseeAve" ){
			
			 
			imageFileNames4.add("TennesseeAve");		  
			
		}
		if ( propertiesOwned.get(i) == "NewYorkAve" ){
			
			 
			imageFileNames4.add("NewYorkAve");		  
			
		}
		if ( propertiesOwned.get(i) == "KentuckyAve" ){
			
			 
			imageFileNames5.add("KentuckyAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "IndianaAve" ){
			
			 
			imageFileNames5.add("IndianaAve");		  
			
		}
		if ( propertiesOwned.get(i) == "IllinoisAve" ){
			
			 
			imageFileNames5.add("IllinoisAve");		  
			
		}
		if ( propertiesOwned.get(i) == "AtlanticAve" ){
			
			 
			imageFileNames6.add("AtlanticAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "VentnorAve" ){
			
			 
			imageFileNames6.add("VentnorAve");		  
			
		}
		if ( propertiesOwned.get(i) == "MarvinGardens" ){
			
			 
			imageFileNames6.add("MarvinGardens");		  
			
		}
		if ( propertiesOwned.get(i) == "PacificAve" ){
			
			 
			imageFileNames7.add("PacificAve");		  
			
		}	
		if ( propertiesOwned.get(i) == "NorthCarolinaAve" ){
			
			 
			imageFileNames7.add("NorthCarolinaAve");		  
			
		}
		if ( propertiesOwned.get(i) == "PennsylvaniaAve" ){
			
			 
			imageFileNames7.add("PennsylvaniaAve");		  
			
		}
		if ( propertiesOwned.get(i) == "ParkPlace" ){
			
			 
			imageFileNames8.add("ParkPlace");		  
			
		}	
		if ( propertiesOwned.get(i) == "Boardwalk" ){
			
			 
			imageFileNames8.add("Boardwalk");		  
			
		}
		 
		if ( propertiesOwned.get(i) == "ReadingRailroad" ){
			
			 
			imageFileNames9.add("ReadingRailroad");		  
			
		}	
		if ( propertiesOwned.get(i) == "B&ORailroad" ){
			
			 
			imageFileNames9.add("B&ORailroad");		  
			
		}
		if ( propertiesOwned.get(i) == "ShortLineRailroad" ){
			
			 
			imageFileNames9.add("ShortLineRailroad");		  
			
		}	
		if ( propertiesOwned.get(i) == "PennsylvaniaRailroad" ){
			
			 
			imageFileNames9.add("PennsylvaniaRailroad");		  
			
		}
		if ( propertiesOwned.get(i) == "ElectricCompany" ){
			
			 
			imageFileNames10.add("ElectricCompany");		  
			
		}	
		if ( propertiesOwned.get(i) == "WaterWorks" ){
			
			 
			imageFileNames10.add("WaterWorks");		  
			
		}
		 
	 
	}
	
	 
	
}
	
	

     

		

    		 
    private  void  displaycards () {
    	
    	int i=0;
    	int j =0;
        GridBagConstraints con = new GridBagConstraints();  
        GridBagConstraints conMargin = new GridBagConstraints();
        con.insets = new Insets (2, 0, 0, 0);
        conMargin.insets = new Insets (2, 20, 0, 0);
        
	      
        if (imageFileNames1.size() > 0)
        {
			        for ( i = 0; i < imageFileNames1.size(); i++) {
			            
				        ImageIcon icon;
				        icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames1.get(i) + imageExt));
				      //  icon  =new ImageIcon(cardsdir + imageFileNames1.get(i) + imageExt));
				                     
					    cardLabel = new JLabel(icon);
					    cardLabel.setToolTipText(imageFileNames1.get(i));
					    con.gridx =j;
					    con.gridy =i +1;
					    add(cardLabel, con);
			      
			        }
			        	j++;
	        	
        }	        	
     
        if (imageFileNames2.size() > 0)
        {  
         for ( i = 0; i < imageFileNames2.size(); i++) {
					ImageIcon icon;
					icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames2.get(i) + imageExt));
					//icon  =new ImageIcon(cardsdir + imageFileNames2.get(i) + imageExt));
					 
					 
					            
					cardLabel = new JLabel(icon);
					cardLabel.setToolTipText(imageFileNames2.get(i));
					con.gridx =j;
					con.gridy =i +1;
					add(cardLabel, con);
		      
		        }
	
         		j++;
         		
        }
        
        if (imageFileNames3.size() > 0)
        {
   
	            for ( i = 0; i < imageFileNames3.size(); i++) {
			          ImageIcon icon;
			          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames3.get(i) + imageExt));
			          //icon  =new ImageIcon(cardsdir + imageFileNames3.get(i) + imageExt));
			 
			           
			     
			                
			          cardLabel = new JLabel(icon);
			          cardLabel.setToolTipText(imageFileNames3.get(i));
			          con.gridx =j;
			          con.gridy =i +1;
			          add(cardLabel, con);
	          
	            }
   
	            j++;
          
        }
        
        if (imageFileNames4.size() > 0)
        {
		            for (  i = 0; i < imageFileNames4.size(); i++) {
			          ImageIcon icon;
			          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames4.get(i) + imageExt));
			        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
			                          
			          cardLabel = new JLabel(icon);
			          cardLabel.setToolTipText(imageFileNames4.get(i));
			          con.gridx =j;
			          con.gridy =i +1;
			          add(cardLabel, con);
		          
		            }
		            j++;
        }           
        
        if (imageFileNames5.size() > 0)
        {
		            
		            for (  i = 0; i < imageFileNames5.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames5.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames5.get(i));
				          con.gridx =j;
				          con.gridy =i+1;
				          add(cardLabel, con);
			          
			            }
		            j++;
        }          
        
        if (imageFileNames6.size() > 0)
        {
		            for (  i = 0; i < imageFileNames6.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames6.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames6.get(i));
				          con.gridx =j;
				          con.gridy =i+1;
				          add(cardLabel, con);
			          
		            	}
		            	j++;
        }           
        
        if (imageFileNames7.size() > 0)
        {
		            for (  i = 0; i < imageFileNames7.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames7.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames7.get(i));
				          con.gridx =j;
				          con.gridy =i+1;
				          add(cardLabel, con);
			          
			            }
		            	j++;
        }          
        
        if (imageFileNames8.size() > 0)
        {
		            for (  i = 0; i < imageFileNames8.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames8.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames8.get(i));
				          conMargin.gridx =j;
				          conMargin.gridy =i+1;
				          add(cardLabel, conMargin);
			          
			            }
		            j++;
        }          
        
        if (imageFileNames9.size() > 0)
        {
		            for (  i = 0; i < imageFileNames9.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames9.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames9.get(i));
				          conMargin.gridx =j;
				          conMargin.gridy =i+1;
				          add(cardLabel, conMargin);
			          
			            }
		            j++;
        }
		            
        if (imageFileNames10.size() > 0)
        {
		            for (  i = 0; i < imageFileNames10.size(); i++) {
				          ImageIcon icon;
				          icon  =new ImageIcon(getClass().getResource(cardsdir + imageFileNames10.get(i) + imageExt));
				        //  icon  =new ImageIcon(cardsdir + imageFileNames4.get(i) + imageExt));
				                          
				          cardLabel = new JLabel(icon);
				          cardLabel.setToolTipText(imageFileNames10.get(i));
				          conMargin.gridx =j;
				          conMargin.gridy =i+1;
				          add(cardLabel, conMargin);
			          
		            }
		            j++;
        }          
		            
	            
   		}          
} 

